<template>
  <page page-background="white">
    <address-item @update="update" @create="create"></address-item>
  </page>
</template>

<script type="text/ecmascript-6">
import addressItem from './common/address-item'
export default {
  components: {
    addressItem
  },
  methods: {
    update (address) {
      let url = '/address/update?type=edit&id='+address.id+'&city_ids='+address.city_ids;
      let allQuery = this.$route.query;
      for(let i in allQuery){
        if(i !== 'type' && i !== 'id'){
          url+=("&"+i+'='+allQuery[i]);
        }
      }
      this.$go(url,false)
    },
    create(){
      let url = '/address/update?type=add';
      let allQuery = this.$route.query;
      for(let i in allQuery){
        if(i !== 'type' && i !== 'id'){
          url+=("&"+i+'='+allQuery[i]);
        }
      }
      this.$go(url,false)
    }
  }
}
</script>
